package com.woniu.serviceprice.controller;

import com.woniu.internalcommon.dto.ForecastPriceDTO;
import com.woniu.internalcommon.dto.ResponseResult;
import com.woniu.serviceprice.service.PriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ForecastPriceController {

    @Autowired
    private PriceService forecastPriceService;

    /**
     * @Description:  计算预估价格
     * @Author:  zcnovice
     * @date:  2025/7/11 上午10:55
     */
    @PostMapping("/forecast-price")
    public ResponseResult forecastPrice(@RequestBody ForecastPriceDTO forecastPriceDTO){


        // 出发地经度
        String depLongitude = forecastPriceDTO.getDepLongitude();
        // 出发地纬度
        String depLatitude = forecastPriceDTO.getDepLatitude();
        // 目的地经度
        String destLongitude = forecastPriceDTO.getDestLongitude();
        // 目的地纬度
        String destLatitude = forecastPriceDTO.getDestLatitude();
        // 城市编码
        String cityCode = forecastPriceDTO.getCityCode();
        // 车辆类型
        String vehicleType = forecastPriceDTO.getVehicleType();


        return forecastPriceService.forecastPrice(depLongitude,depLatitude,destLongitude,destLatitude,cityCode,vehicleType);
    }

    /**
     * @Description:  计算实际价格
     * @Author:  zcnovice
     * @date:  2025/7/11 上午10:55
     */
    @PostMapping("/calculate-price")
    public ResponseResult<Double> calculatePrice(@RequestParam("distance") Integer distance , @RequestParam("duration") Integer duration, @RequestParam("cityCode") String cityCode, @RequestParam("vehicleType") String vehicleType){
        return forecastPriceService.calculatePrice(distance,duration,cityCode,vehicleType);
    }


}
